package com.yidu.hbatsams.service.Impl;

import com.github.pagehelper.PageHelper;
import com.yidu.hbatsams.dao.AtsEmpCoachAthleteMapper;
import com.yidu.hbatsams.domain.AtsEmpCoachAthlete;
import com.yidu.hbatsams.service.emp.AtsEmpCoachAthleteService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Date;
import java.util.List;
@Service
public class AtsEmpCoachAthleteServiceImpl implements AtsEmpCoachAthleteService {
    @Resource
    AtsEmpCoachAthleteMapper atsEmpCoachAthleteMapper;
    /**
     * 查询所有加模糊查询
     * @param coachName
     * @return
     */
    public List<AtsEmpCoachAthlete> findAll(Integer pageNum, Integer pageSize,String coachName) {
        PageHelper.startPage(pageNum,pageSize);
        List<AtsEmpCoachAthlete> ats = atsEmpCoachAthleteMapper.findAll(coachName);
        return ats;
    }

    /**
     * 查询行数
     * @return
     */
    public Long count() {
        System.out.println(
                "教练运动员的查询行数实现类"
        );
        return atsEmpCoachAthleteMapper.count();
    }

    /**
     * 逻辑删除
     * @param caId
     * @return
     */
    public int deleteByPrimaryKey(Integer caId) {
        return atsEmpCoachAthleteMapper.deleteByPrimaryKey(caId);
    }

    /**
     * 根据ID查询
     * @param caId
     * @return
     */
    @Override
    public AtsEmpCoachAthlete selectByPrimaryKey(Integer caId) {
        return atsEmpCoachAthleteMapper.selectByPrimaryKey(caId);
    }

    /**
     * 新增
     * @param record
     * @return
     */
    public int insert(AtsEmpCoachAthlete record) {
        System.out.println("新增的实现类");
        record.setIsva(1);
        record.setCreatTime(new Date(System.currentTimeMillis()));
        int ats = atsEmpCoachAthleteMapper.insert(record);
        return ats;
    }

    /**
     * 修改
     * @param record
     * @return
     */
    public int updateByPrimaryKey(AtsEmpCoachAthlete record) {
        System.out.println("修改的实现类");
        record.setIsva(1);
        record.setCreatTime(new Date(System.currentTimeMillis()));
        int ats = atsEmpCoachAthleteMapper.updateByPrimaryKey(record);
        return ats;
    }

    /**
     * 查询教练运动员信息
     * @param athleteId
     * @param coachId
     * @return
     */
    public AtsEmpCoachAthlete findAllMess(Integer athleteId, Integer coachId) {
        return atsEmpCoachAthleteMapper.findAllMess(athleteId,coachId);
    }
}
